﻿using AccompanyCabinet.Helper;
using AccompanyCabinet.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AccompanyCabinet.Admin
{
    public partial class SearchOrder : Form
    {
        public SearchOrder()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            kb.Close();
            string url = "TerminalInfo/SearchDevBox";
            var res = HttpHelper.Get(url+ "?TradeNum="+txt_ordernum.Text+"");
            if (res.status == "OK")
            {
                SearchOrderModel search = JsonConvert.DeserializeObject<SearchOrderModel>(res.Message);
                lab_num.Text = search.Num.ToString();
                lab_price.Text = search.Price.ToString();
                lab_startTime.Text = search.StartTime.ToString();
            }
            else
            {
                MessageBox.Show(res.Message);
                return;
            }
        }
        CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
        private void btn_return_Click(object sender, EventArgs e)
        {
            kb.Close();
            this.Hide();
            new Index().Show();
        }

        private void txt_ordernum_MouseClick(object sender, MouseEventArgs e)
        {
            CabinetControl.KeyBoard kb = CabinetControl.KeyBoard.CreateInstrance();
            kb.Location = new Point(PointToScreen(txt_ordernum.Location).X + 65, PointToScreen(txt_ordernum.Location).Y + 65);
            txt_ordernum.Focus();
            txt_ordernum.Invoke(new Action(() => { kb.Show(); }));
            Activate();
        }
    }
}
